package com.uniledger.exchange.wallet.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.uniledger.exchange.base.fragment.BaseFragment;

public abstract class MnemonicFragment extends BaseFragment implements View.OnClickListener{

    protected OnMnemonicListener listener;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (context instanceof OnMnemonicListener) {
            listener = (OnMnemonicListener) context;
        } else {
            throw new RuntimeException(context.toString()
                    + " must implement OnBackupListener");
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        listener = null;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        if (listener!=null){
            listener.getButton().setOnClickListener(this);
        }
    }
}
